/*

This file is part of Rooms3D.

Copyright (C) 2008 Pixecur Technologies Incorporated (Esotera).
Visit Esotera at http://www.esoteras3.com
 
Rooms3D is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 3, or (at your option)
any later version.
 
Rooms3D is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
General Public License for more details.
 
You should have received a copy of the GNU General Public License
along with Rooms3D; see the file COPYING.  If not, write to 
Pixecur Technologies, 213-31 Peet Street, St. John's, NL, A1B 3W8. 
 
Linking this library statically or dynamically with other modules is
making a combined work based on this library.  Thus, the terms and
conditions of the GNU General Public License cover the whole
combination.
 
*/

package com.datasentinel.j3d.controls.hud;

import javax.swing.event.ChangeListener;

import com.datasentinel.j3d.controls.ChangeEventSupport;

public class HeadsUpDisplayModel
{
	
	private final static int MAX_CURRENT_ADDRESS_LENGTH = 50;
	private final static int MAX_CURRENT_FILE_LENGTH = 40;
	
	private ChangeEventSupport changeEventSupport = new ChangeEventSupport();
	
	private String currentAddress;
	private String currentFile;
	
	private boolean showProgress;
	
	public boolean isShowProgress()
	{
		return showProgress;
	}

	public void setShowProgress(boolean showProgress)
	{
		boolean valueChanged = this.showProgress != showProgress;
		
		this.showProgress = showProgress;
		
		if(showProgress == false)
			showProgress = showProgress;
		if(valueChanged)
			fireStateChanged();
	}

	public String getCurrentAddress()
	{
		return currentAddress;
	}

	public void setCurrentAddress(String currentAddress)
	{
		this.currentAddress = currentAddress;
		
		if(currentAddress != null)
		{
			if(currentAddress.length() > MAX_CURRENT_ADDRESS_LENGTH)
			{
				this.currentAddress =  "..." + currentAddress.substring(currentAddress.length() - (MAX_CURRENT_ADDRESS_LENGTH - 3));
			}
		}
		
		fireStateChanged();
	}

	public String getCurrentFile()
	{
		return currentFile;
	}

	public void setCurrentFile(String currentFile)
	{
		this.currentFile = currentFile;
		
		if(currentFile != null)
		{
			if(currentFile.length() > MAX_CURRENT_FILE_LENGTH)
			{
				this.currentFile =  "..." + currentFile.substring(currentFile.length() - (MAX_CURRENT_FILE_LENGTH - 3));
			}
		}
		
		fireStateChanged();
	}
	
	
	public void addChangeListener(ChangeListener l)
	{
		changeEventSupport.addChangeListener(l);
	}

	public void removeChangeListener(ChangeListener l)
	{
		changeEventSupport.removeChangeListener(l);
	}

	protected void fireStateChanged()
	{
		changeEventSupport.fireStateChanged();
	}
	
}
